package shujia.day04.ketang;

/*
    2个对象的内存图
    其中有两个引用指向同一个对象

 */
public class Student2 {
    String id;
    String name;
    int age;

    public void eat() {
        System.out.println("吃饭");
    }

    public void study(String n) {
        System.out.println("学习 " + n);
    }
}

class StudentDemo2 {
    public static void main(String[] args) {
        //创建第一个对象
        Student2 s1 = new Student2();
        s1.id = "1001";
        s1.name = "张三";
        s1.age = 17;
        System.out.println("学号：" + s1.id + ", 姓名：" + s1.name + ", 年龄：" + s1.age);
        s1.eat();
        s1.study("大数据");
        System.out.println("--------------------------------");
        Student2 s2 = s1;
        System.out.println("学号：" + s2.id + ", 姓名：" + s2.name + ", 年龄：" + s2.age);
        s2.age = 100;
        System.out.println("=======");
        System.out.println("学号：" + s1.id + ", 姓名：" + s1.name + ", 年龄：" + s1.age);
        System.out.println("学号：" + s2.id + ", 姓名：" + s2.name + ", 年龄：" + s2.age);

    }
}
